package BasicClass.One;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BasicOne9 {
    public static void main(String[] args) throws IOException {
        BasicOne9 basicOne9 = new BasicOne9();
        basicOne9.Main();
    }

    /**
     * 给你一个n代表有一个长度为n的有序数组，然后给你一个k，你需要判断这个k是否在数组里面，
     * 如果存在就返回这个数第一次出现位置的下标，如果不存在输出-1
     */
    public void Main() throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s = reader.readLine().split(" ");
        int size = Integer.parseInt(s[0]);
        int num = Integer.parseInt(s[1]);
//        System.out.println("大小:"+size+":"+num);
        String[] nums = reader.readLine().split(" ");
        int[] ints = new int[size];
        for (int i = 0; i < size; i++) {
            ints[i]=Integer.parseInt(nums[i]);
        }
        int left = 0;
        int right = size-1;
        int mid = 0;
        while (left<right){
            mid = ((right-left)>>1)+left;
            if(ints[mid]==num){
                mid = helper(ints,num,mid);
                break;
            }else if(ints[mid]>num){
                right = mid-1;
            }else {
                left = mid+1;
            }
        }
        if(ints[mid]==num){
            System.out.println(mid);
        }else if(ints[left]==num){
            System.out.println(left);
        }else {
            System.out.println(-1);
        }
    }

    public int helper(int[] ints,int num,int mid){
        while (mid!=0 && ints[mid-1]==num){
            mid--;
        }
        return mid;
    }
}
